package com.example.springboot.config.anotation.conditionOn.confitional;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Component;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/7/9 15:14
 */
@Component
public class ChinaCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        System.out.println("===判断是否是中文环境了=======");
        Environment environment = context.getEnvironment();
        // 是否是中文环境
        return environment.containsProperty("ENV_CN");
    }
}
